﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Net;
using HtmlAgilityPack;
using System.IO;
using WebDUPlugIn.Processors;
using WebDUPlugIn.ConfigAndModels;
using System.Xml;

namespace WebDUUnitTest
{
    [TestClass]
    public class TACrawlTests
    {
        [TestMethod]
        public void TestMethod1()
        {
            var testUri = "http://www.tripadvisor.com/Hotel_Review-g60878-d613399-Reviews-Hotel_1000-Seattle_Washington.html";
            var crawlRequest = (HttpWebRequest)WebRequest.Create(testUri);
            crawlRequest.UserAgent = "Mozilla/5.0 (compatible;Windows NT 6.1; WOW64; ENUS) Gecko/20100101 Firefox/13.0.1";
            crawlRequest.ContentType = "text/html,application/xhtml+xml,application/xml,*/*";
            //2. Get HTML Content ...
            var response = (HttpWebResponse)crawlRequest.GetResponse();

            // Read Content .. 
            var htmlStreamReader = new StreamReader(response.GetResponseStream());
            var htmlContent = htmlStreamReader.ReadToEnd();
            htmlStreamReader.Close();

            HtmlDocument doc = new HtmlDocument();
            doc.LoadHtml(htmlContent);

            TADVExtract taData = new TADVExtract();
            DocumentToProcess docP = new DocumentToProcess(new Uri(testUri), doc);
            var prop = taData.processrawData("sample",docP,null);

            
        }
    }
}
